{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Category Plots, aka Bar Charts"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from beakerx import *\n",
    "bars = CategoryBars(value = [[1, 2, 3], [1, 3, 5]])\n",
    "CategoryPlot().add(bars)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "the initWidth and initHeight properties"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "cplot = CategoryPlot(initWidth = 400, initHeight = 200)\n",
    "bars = CategoryBars(value = [[1, 2, 3], [1, 3, 5]])\n",
    "cplot.add(bars)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "the title, x and y axis labels"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "cplot = CategoryPlot(title = \"Hello CategoryPlot!\",\n",
    "                             xLabel = \"Categories\",\n",
    "                             yLabel = \"Values\")\n",
    "cplot.add(CategoryBars(value = [[1, 2, 3], [1, 3, 5]]))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "the category labels"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "cplot = CategoryPlot(categoryNames =  [\"Helium\", \"Neon\", \"Argon\"])\n",
    "cplot.add(CategoryBars(value = [[1, 2, 3], [1, 3, 5]]))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "the series labels"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "bars = CategoryBars(value = [[1, 2], [3, 4], [5, 6], [7, 8]],\n",
    "                            seriesNames = [\"Gas\", None, \"\", \"Liquid\"])\n",
    "CategoryPlot().add(bars)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "the legend"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "plot = CategoryPlot(showLegend = True) \n",
    "# since no display names were provided, default names \"series0\" etc will be used.\n",
    "plot.add(CategoryBars(value = [[1, 2, 3], [1, 3, 5]]))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "the orientation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "plot = CategoryPlot(orientation = PlotOrientationType.HORIZONTAL)\n",
    "plot.add(CategoryBars(value = [[1, 2, 3], [1, 3, 5]]))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "the label angle"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "plot = CategoryPlot(categoryNames = [\"Acid\", \"Neutral\", \"Base\"], \n",
    "                            categoryNamesLabelAngle = -1/4 * math.pi)\n",
    "plot.add(CategoryBars(value = [[1, 2, 3], [4, 5, 6]]))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "the margin"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "plot = CategoryPlot(categoryMargin = 2)\n",
    "plot.add(CategoryBars(value = [[1, 2, 3], [4, 5, 6]]))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "the color (single value)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "bars = CategoryBars(value = [[1, 2], [3, 4], [5, 6]], \n",
    "                            color = Color.pink)\n",
    "CategoryPlot().add(bars)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "the color (list of values)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "colors = [Color.pink, [Color.red, Color.gray, Color.blue]]\n",
    "bars = CategoryBars(value = [[1, 2, 3], [4, 5, 6]], \n",
    "                            color = colors)\n",
    "CategoryPlot().add(bars)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "the base (single value)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "bars = CategoryBars(value = [[1, 2, 3], [4, 5, 6]], \n",
    "                            base = -2)\n",
    "CategoryPlot().add(bars)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "the base (list of values)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "bars = CategoryBars(value = [[1, 2, 3], [4, 5, 5]],\n",
    "                            base = [-2, [-4, -4, -1]])\n",
    "CategoryPlot().add(bars)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "the width (single value)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "bars = CategoryBars(value = [[1, 2, 3], [4, 5, 6]],\n",
    "                            width = 0.3)\n",
    "CategoryPlot().add(bars)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "the width (list of values)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "bars = CategoryBars(value = [[1, 2, 3], [4, 5, 6]],\n",
    "                            width = [[0.3, 0.6, 1.7], 1.0])\n",
    "CategoryPlot().add(bars)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "the fill (single value)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "bars = CategoryBars(value = [[1, 2, 3], [4, 5, 6]],\n",
    "                            fill = [False, False])\n",
    "CategoryPlot().add(bars)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "the fill (list of values)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "bars = CategoryBars(value = [[1, 2, 3], [4, 5, 6]],\n",
    "                            fill = [[False, True, False], True])\n",
    "CategoryPlot().add(bars)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "draw outline (single value)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "bars = CategoryBars(value = [[1, 2, 3], [4, 5, 6]],\n",
    "                            drawOutline = True)\n",
    "CategoryPlot().add(bars)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "draw outline (list of values)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "bars = CategoryBars(value = [[1, 2, 3], [4, 5, 6]],\n",
    "                    drawOutline = [[False, True, False], True])\n",
    "CategoryPlot().add(bars)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "outline color (single value)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "bars = CategoryBars(value = [[1, 2, 3], [4, 5, 6]],\n",
    "                    drawOutline = True,\n",
    "                    outlineColor = Color.green)\n",
    "CategoryPlot().add(bars)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "outline color (list of values)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "bars = CategoryBars(value = [[1, 2, 3], [4, 5, 6]],\n",
    "                    drawOutline = True,\n",
    "                    outlineColor = [Color.green, Color.red])\n",
    "CategoryPlot().add(bars)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": false,
   "sideBar": false,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": false,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
